cmake_minimum_required(VERSION 3.0)

message(STATUS "register CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message(STATUS "register CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")

include(${CMAKE_SOURCE_DIR}/include/common/CMakeLists.txt) 

set(REGISTER_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
set(REGISTER_SRCPATH ${CMAKE_SOURCE_DIR}/src/register)
set(REGISTER_SOURCE
    ${REGISTER_SRCPATH}/register.c
)

add_executable(register ${REGISTER_SOURCE} ${COMMON_SOURCES})
target_include_directories(register PRIVATE
    ${REGISTER_INCLUDE_DIRS}
    ${COMMON_INCLUDE_DIRS}
    ${MySQL_INCLUDE_DIRS}
    ${Hiredis_INCLUDE_DIRS}
    ${FCGI_INCLUDE_DIRS}
)

# 链接外部库
if (MySQL_FOUND)
    target_link_libraries(register PRIVATE ${MYSQL_LIBRARIES})
    message(STATUS "Link_libraries MySQL_LIBRARIES = ${MYSQL_LIBRARIES}")
endif()

if (OpenSSL_FOUND)
    target_link_libraries(register PRIVATE ${OPENSSL_LIBRARIES})
    message(STATUS "Link_libraries OPENSSL_LIBRARIES = ${OPENSSL_LIBRARIES}")
endif()

if (FCGI_FOUND)
    target_link_libraries(register PRIVATE ${FCGI_LIBRARIES})
    message(STATUS "Link_libraries FCGI_LIBRARIES = ${FCGI_LIBRARIES}")
endif()

if(Hiredis_FOUND)
    target_link_libraries(register PRIVATE ${Hiredis_LIBRARIES})
    message(STATUS "Link_libraries Hiredis_LIBRARIES = ${Hiredis_LIBRARIES}")
endif()

target_link_libraries(register PRIVATE m)